home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 …ember: Reference Library / Dev.CD Dec 00 RL Disk 1.toast / mac / Technical Documentation / Develop / develop Issue 24 / develop Issue 24 code / Scriptable Database 1.0a15.sea / Scriptable Database 1.0a15 / Database / AbstractUpdatePointer.h / AbstractUpdatePointer.h
Encoding:
Text File  |  1996-04-29  |  2.5 KB  |  83 lines  |  [TEXT/CWIE]

  1. //================================================================================
  2. // Greg Anderson
  3. // db+
  4. //
  5. // Abstract base class for update pointers
  6. // 16 May 1994
  7. //================================================================================
  8. #pragma once
  9.  
  10. #ifndef __ABSTRACTUPDATEPOINTER__
  11. #define __ABSTRACTUPDATEPOINTER__
  12.  
  13. #include "TransactionAwareObject.h"
  14.  
  15. #include "Int64.h"
  16.  
  17. //
  18. // For REQUIREVALIDPOINTER
  19. //
  20. #include "Debug.h"
  21.  
  22. //
  23. // Still needed?
  24. //
  25. #include "Exceptions.h"
  26.  
  27. //
  28. // Our abstract update pointer class knows about all of
  29. // the classes of objects that may have update pointers
  30. // so that it may provide type-safe downcasting.
  31. //
  32. class TAbstractRecord;
  33. class TBlockDataRecord;
  34. class TDBRecordUpdatePointer;
  35. class TDBElementUpdatePointer;
  36. class TDBPropertyUpdatePointer;
  37.  
  38. //================================================================================
  39. // class TAbstractUpdatePointer
  40. //
  41. // We want a base class for our update pointers so that we can have a typeless
  42. // base class for our update pointer collection
  43. //================================================================================
  44. class TAbstractUpdatePointer : public TTransactionBaseObject
  45. {
  46.     //
  47.     // A transaction is a friend of an update pointer, because only
  48.     // transactions may call commit and discard changes on an update pointer
  49.     //
  50.     friend class TTransaction;
  51.  
  52. private:
  53.     const TTransaction*                    fTransaction;
  54.         
  55. public:
  56.             TAbstractUpdatePointer(const TTransaction* transaction) : fTransaction(transaction) { REQUIREVALIDPOINTER(transaction); };
  57.     virtual ~TAbstractUpdatePointer();
  58.     
  59.     virtual TTransactionAwareObject*    ChangeObject() const = 0;
  60.  
  61.     virtual TDBRecordUpdatePointer*        DBRecordUpdatePointer();
  62.     virtual TDBElementUpdatePointer*    ObjectRecordUpdatePointer();
  63.     virtual TDBPropertyUpdatePointer*    DataRecordUpdatePointer();
  64.  
  65.     //
  66.     // Most methods inherited from TTransactionAwareObject
  67.     // call through to the object being changed
  68.     //
  69.     virtual Int64 ObjectsKeySpace() const { return this->ChangeObject()->ObjectsKeySpace(); };
  70.     virtual long ObjectKey() const        { return this->ChangeObject()->ObjectKey(); };
  71.  
  72. protected:
  73.     //
  74.     // Only an object's update pointer may call its Commit / Discard changes methods
  75.     //
  76.     // ◊const TTransaction* cast away; should we remove the 'const' from fTransaction entirely?
  77.     //
  78.     virtual void CommitChanges()        { this->ChangeObject()->CommitChanges((TTransaction*)fTransaction); };
  79.     virtual void DiscardChanges()        { this->ChangeObject()->DiscardChanges((TTransaction*)fTransaction); };
  80. };
  81.  
  82. #endif
  83.